package controller;
import com.sun.javafx.binding.StringFormatter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class Ajax {
    @RequestMapping("/qwe")
    public String ajax(){
        return "hello";
    }
    @RequestMapping("/okk")
    public String testInterceptor(){
        System.out.println("拦截器执行了");
        return "Ok";
    }
    @RequestMapping("/login")
    public String mainLogin(){
        return "login";
    }
    @RequestMapping("/goMain")
    public String goMain(){
        return "maininterface";
    }
    @RequestMapping("/realLogin")
    public String realLogin(HttpSession session ,String account ,String password){
        if (account.equals("jiaSen")&&password.equals("123456")){
            //账号密码正确将数据保存在session域中 跳转到 主界面
            session.setAttribute("user",account);
            return "maininterface";
        }else {
            //跳转到重新登录界面
            return "login";
        }
    }
    @RequestMapping("/goOut")
    public String goOut(HttpSession session ){
        session.removeAttribute("user");
        return "maininterface";
    }
}
